package com.v.im.websocketservice.kafkaconsumer.deserializer;

import com.alibaba.fastjson.JSON;
import com.v.im.commonmodule.utils.chat.Message;
import org.apache.kafka.common.serialization.Deserializer;

import java.util.Map;

public class MessageDeserializer implements Deserializer<Message> {


    @Override
    public void configure(Map<String, ?> map, boolean b) {

    }

    @Override
    public Message deserialize(String topic, byte[] bytes) {
        if (bytes.length == 0) {
            return new Message();
        }
        String messageStr = new String(bytes);
        return JSON.parseObject(messageStr, Message.class);
    }

    @Override
    public void close() {

    }
}
